/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package data;
import java.sql.Connection;
import java.sql.Statement;
/**
 *
 * @author NS
 */
public class Role_Grant{
    private Connection conn;
    public Role_Grant(Connection conn){
        this.conn = conn;
    }
    public String grant(String username, String role){
        Statement stmt;
        try{
            stmt = conn.createStatement();
            System.out.println("GRANT " + role + " TO " + username);
            stmt.executeUpdate("GRANT " + role + " TO " + username);
            
            System.out.println("UPDATE USERTBL SET ROLE = '" + role + 
                               "' WHERE USERNAME = '" + username + "'");
            stmt.executeUpdate("UPDATE USERTBL SET ROLE = '" + role + 
                               "' WHERE USERNAME = '" + username + "'");
            return "success";
        }catch(Exception e){
            return e.getMessage();
        }
    }
}
